Skip to content

fix(machine): reject non-object config snapshots - #388

Merged
StepenkoAnatoli merged 1 commit into
mainfrom
fix/issue-368-config-snapshot
Oct 14, 2026
Merged

StepenkoAnatoli merged 1 commit into
mainfrom
fix/issue-368-config-snapshot

Conversation

@StepenkoAnatoli

Copy link
Copy Markdown
Owner

Non-object JSON backups such as [] and "x" were treated as last-good machine settings. When the live config then stopped parsing, the kit silently restored collector and fail-open defaults. Only non-array JSON objects may now create or restore the backup; unusable backups take the existing fail-closed/unknown-role fallback. Reading a scalar or array leaves an existing good backup intact.

Fixes #368

what changed: Guarded snapshot creation and restoration, and added regressions for invalid backup shapes and preservation of a previously valid backup.

why: Restore ADR-0020 and ADR-0023's existing behavior when there are no settings to hold. No alternative design was set aside.

what it touched: lib/machine.mjs, machine tests, architecture map row, changelog and README test inventory. No new setting or interface.

what you verified: verified - red-first reproduction, followed by 25 passing machine tests; handoff OK and root preflight PASS. The required full-suite commit gate accepted this commit.

what you got wrong and fixed: nothing to report.

Full-suite detail: verified - 1779 passed, 0 failed, 12 unsupported capabilities on Windows/Node 24.20.0 in 1122.7 seconds, accepted under the gate's documented local policy. GitHub CI runs separately.

what changed: Only non-array JSON objects may create or restore a last-good machine config snapshot. Added regressions for arrays, strings, numbers, booleans and null, plus preservation of an existing good backup.

why: A JSON scalar or array holds no machine settings; restoring it after a parse failure silently enabled collector and fail-open defaults. Apply the existing ADR-0020/0023 fallback instead. No alternative design was set aside.

what it touched: machine.mjs, machine tests, architecture map, changelog and README test inventory. No new config key, role or public interface.

what you verified: verified - red-first reproduction (23 passed, two expected failures), then machine tests (25 passed, zero failures); handoff OK; root preflight PASS with its existing unstamped-brief warning; doctor READY on the collector with firecrawl-cli. The required full suite runs in the commit gate before acceptance.

what you got wrong and fixed: nothing to report.
@StepenkoAnatoli
StepenkoAnatoli merged commit 0dc3ff0 into main Oct 14, 2026
7 checks passed
@StepenkoAnatoli
StepenkoAnatoli deleted the fix/issue-368-config-snapshot branch October 14, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A .last-good snapshot that is an array or a string is 'held', so a broken config resolves to collector and fail-open instead of unknown and fail-closed

1 participant